#include <cstdio>
#include "FConstants.h"
#include "FPodReader.h"


/**
 * TODOC
 */
void FConstants::load(FPodReader& reader)
{
  this->loadInts(reader);
  this->loadFloats(reader);
  this->loadStrings(reader);
  this->loadDurations(reader);
  this->loadURIs(reader);
}


/**
 * TODOC
 */
void FConstants::loadInts(FPodReader& reader)
{
  m_ints.clear();
  if (reader.setCurrentFile("ints.def"))
  {
    uint16_t numInts = reader.readUInt16();
    for (uint16_t i = 0; i < numInts; i++)
      m_ints.push_back(reader.readInt64());
  }
}


/**
 * TODOC
 */
void FConstants::loadFloats(FPodReader& reader)
{
  m_floats.clear();
  if (reader.setCurrentFile("reals.def"))
  {
    uint16_t numFloats = reader.readUInt16();
    for (uint16_t i = 0; i < numFloats; i++)
      m_floats.push_back(reader.readDouble());
  }
}


/**
 * TODOC
 */
void FConstants::loadStrings(FPodReader& reader)
{
  m_strings.clear();
  if (reader.setCurrentFile("strs.def"))
  {
    uint16_t numStrings = reader.readUInt16();
    for (uint16_t i = 0; i < numStrings; i++)
      m_strings.push_back(reader.readString());
  }
}


/**
 * TODOC
 */
void FConstants::loadDurations(FPodReader& reader)
{
  m_durations.clear();
  if (reader.setCurrentFile("durations.def"))
  {
    uint16_t numDurations = reader.readUInt16();
    for (uint16_t i = 0; i < numDurations; i++)
      m_durations.push_back(reader.readInt64());
  }
}


/**
 * TODOC
 */
void FConstants::loadURIs(FPodReader& reader)
{
  m_durations.clear();
  if (reader.setCurrentFile("uris.def"))
  {
    uint16_t numURIs = reader.readUInt16();
    for (uint16_t i = 0; i < numURIs; i++)
      m_URIs.push_back(reader.readString());
  }
}
